CREATE DATABASE MYSITEB2C  
GO
USE MYSITEB2C 
----------------------------------------------------------
GO 
CREATE TABLE TBL_ROLE 
(
	ID_ROLE INT IDENTITY(1,1) PRIMARY KEY ,
	NAMEROLE NVARCHAR(20) NOT NULL ,
	CONTENT NTEXT NOT NULL 
)
----------------------------------------------------------
GO 
CREATE TABLE TBL_MEMBER 
(
	ID_MEMBER INT IDENTITY(1,1) PRIMARY KEY , 
	ID_ROLE INT NOT NULL , 
	USERNAME NVARCHAR(20) NOT NULL  UNIQUE, 
	PASSWORD NVARCHAR(20) NOT NULL ,
	FULLNAME NVARCHAR(50),
	BIRTHDAY CHAR(10), 
	IDENTIFICATION CHAR(9), 
	ADDRESS NVARCHAR(50),
	PHONE CHAR(12),
	EMAIL NVARCHAR(20) NOT NULL UNIQUE , 
	SEX CHAR(3),
	URLAVATAR NVARCHAR(100),
	SLOGAN NVARCHAR(200), 
	STATUS NVARCHAR(200),
	JOINDATE DATETIME , 
	CONSTRAINT PK_RM FOREIGN KEY (ID_ROLE) REFERENCES TBL_ROLE(ID_ROLE)
)

----------------------------------------------------------------------------
GO 
CREATE TABLE TBL_CATELOGIES 
(
	ID_CATELOGIES INT IDENTITY(1,1) PRIMARY KEY ,
	NAMECATELOGIES NVARCHAR(150)
)
----------------------------------------------------------------------------
GO 
CREATE TABLE TBL_PRODUCT
(
	ID_PRODUCT INT IDENTITY(1,1) PRIMARY KEY ,
	NAMEPRODUCT NVARCHAR(150) NOT NULL , 
	DESCRIPPRODUCT NTEXT , 
	COSTPRODUCT FLOAT , 
	ID_CATELOGIES INT , 
	POSTDATE DATETIME , 
	STATUSPRODUCT BIT DEFAULT 0 , 
	ISSALE BIT DEFAULT 0 
)
------------------------------------------------------------------------------

GO 
CREATE TABLE TBL_ORDER 
(
	ID_ORDER INT IDENTITY(1,1) PRIMARY KEY , 
	ID_MEMBER INT NOT NULL , 
	FIRSTNAME NVARCHAR(50),
	LASTNAME NVARCHAR(50),
	ADRESS NVARCHAR(200),
	CITY NVARCHAR(50),
	COUNTRY NVARCHAR(50),
	STATUS BIT DEFAULT 0 , 
	BUYDATE DATETIME, 
	CONSTRAINT FK_OM FOREIGN KEY (ID_MEMBER) REFERENCES TBL_MEMBER(ID_MEMBER)
)
------------------------------------------------------------------------------
GO 
CREATE TABLE TBL_DETAILORDER 
(
	ID_DETAILORDER INT IDENTITY(1,1), 
	ID_ORDER INT  NOT NULL,
	ID_PRODUCT INT NOT NULL , 
	COUNTPRODUCT INT , 
	COSTPRODUCT FLOAT,
	CONSTRAINT PK_DP PRIMARY KEY (ID_DETAILORDER,ID_ORDER) , 
	CONSTRAINT FK_DO FOREIGN KEY (ID_ORDER) REFERENCES TBL_ORDER(ID_ORDER),
	CONSTRAINT FK_DOP FOREIGN KEY (ID_PRODUCT) REFERENCES TBL_PRODUCT(ID_PRODUCT)
)
---------------------------------------------------------------------------------------
GO 
CREATE TABLE TBL_LOGO 
(
	ID_LOGO INT IDENTITY(1,1) PRIMARY KEY , 
	URLLOGO NVARCHAR(150) , 
	ALTLOGO NVARCHAR(100)
)
---------------------------------------------------------------------------------------
GO 
CREATE TABLE TBL_FLASHCOMPANY
(
	ID_FLASHCOMPANY INT IDENTITY(1,1) PRIMARY KEY , 
	URLFLASH NVARCHAR(150), 
	ALTFLASH NVARCHAR(100)
)
---------------------------------------------------------------------------------------
GO 
CREATE TABLE TBL_EVENT 
(
	ID_EVENT INT IDENTITY(1,1) PRIMARY KEY , 
	TITLE NTEXT NOT NULL , 
	URLIMAGEEVENT NVARCHAR(150),
	DATECREATE DATETIME
)
---------------------------------------------------------------------------------------
GO 
CREATE TABLE TBL_TOPMENU 
(
	ID_TOPMENU INT IDENTITY(1,1) PRIMARY KEY , 
	NAMEMENU NVARCHAR(30),
	URLMENU NVARCHAR(150)
)
---------------------------------------------------------------------------------------
GO 
CREATE TABLE TBL_IMAGEPRODUCT 
(
	ID_IMAGEPRODUCT INT IDENTITY(1,1) PRIMARY KEY , 
	ID_PRODUCT INT NOT NULL , 
	URLIMAGE NVARCHAR(100), 
	CONSTRAINT PK_IMP FOREIGN KEY (ID_PRODUCT) REFERENCES TBL_PRODUCT(ID_PRODUCT)
) 
---------------------------------------------------------------------------------------
GO 
CREATE TABLE TBL_INFOSUPORT 
(
	ID_INFOSUPORT INT IDENTITY(1,1) PRIMARY KEY , 
	URLMAIL NVARCHAR(300) NOT NULL 
)
---------------------------------------------------------------------------------------
GO 
CREATE TABLE TBL_COMMENT 
(
	ID_COMMENT INT IDENTITY(1,1) PRIMARY KEY , 
	ID_PRODUCT INT NOT NULL , 
	ID_MEMBER INT NOT NULL , 
	CONTENT NTEXT , 
	DATECOMMENT DATETIME ,
	CONSTRAINT FK_CP FOREIGN KEY (ID_PRODUCT) REFERENCES TBL_PRODUCT(ID_PRODUCT),
	CONSTRAINT FK_CM FOREIGN KEY (ID_MEMBER) REFERENCES TBL_MEMBER(ID_MEMBER)
)
------------------------------------------------------------------------------------------
GO 
CREATE TABLE TBL_COMPANY
(
	ID_COMPANY INT IDENTITY(1,1) PRIMARY KEY , 
	ID_MEMBER INT  NOT NULL ,
	CONTENT NTEXT , 
	CONSTRAINT FK_PM FOREIGN KEY (ID_MEMBER) REFERENCES TBL_MEMBER(ID_MEMBER) 
)


















